package com.xmgl.test;

import java.net.UnknownHostException;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-beans.xml")
public class DBUtil {

	@Autowired
	private JdbcTemplate jdbcTemplate;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
	}
	
	@Test
	public void testAddData(){
		for(int i = 0;i<10;i++){

//			document.put("id", i);
//			document.put("name", "雨夜带刀要饭");
//			document.put("hobby", "love "+i+" girl");
//			document.put("age", i%39+1);
//			collection.save(document);
			jdbcTemplate.update("insert into  testTable (name,age,hobby) values (?,?,?)", "雨夜带刀",(i%39+1),"love "+i+" girl");
		}
	}

}
